﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using Entitas;

namespace Internal
{
    public class PositionSystem : ReactiveSystem<GameEntity>
    {

        public PositionSystem(Contexts contexts) : base(contexts.game)
        {

        }

        protected override ICollector<GameEntity> GetTrigger(IContext<GameEntity> context)
        {
            return context.CreateCollector(GameMatcher.InternalPositon);
        }

        protected override bool Filter(GameEntity entity)
        {
            return entity.hasInternalPositon && entity.hasInternalView;
        }

        protected override void Execute(List<GameEntity> entities)
        {
            foreach (GameEntity item in entities)
            {
                item.internalView.viewTrans.position = item.internalPositon.pos;
            }
        }




    }
}

